<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>

<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/swfobject.js"></script>

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />

<title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
<?php wp_head(); ?>
</head>
<body><div id="page">

<div id="header">
	<?php
		// where the links swf is
    	$foto_blog_links = implode( "/", explode( "/", $_SERVER['SCRIPT_FILENAME'], -1 ) )."/wp-content/themes/fotoblog/images/FotoBlogLinks.swf";
		//$foto_blog_links = "foo";
		$pages = get_pages();
		if( file_exists( $foto_blog_links ) ) { ?>
    <div id="headerRightFlash">&nbsp;</div>
    <script type="text/javascript">
		// <![CDATA[
			var so = new SWFObject("<?php bloginfo('stylesheet_directory'); ?>/images/FotoBlogLinks.swf", "FotoBlogLinks", "400", "80", "9", "#FFFFFF");
			so.addParam("wmode", "transparent");
			so.addVariable("current", "<?php if( is_front_page() ) { echo "home"; } else { echo trim( wp_title('',false) ); } ?>");
			so.addVariable("arg0_title", "Home");
			so.addVariable("arg0_guid", "<?php echo implode( explode( '/', $_SERVER['PHP_SELF'], -1 ) , "/" ); ?>");
<?php
			foreach( $pages as $i => $page )
			{
				if( $page->post_status == "publish" )  {
					echo "			so.addVariable(\"arg".($i+1)."_title\", \"".$page->post_title."\");\n";
					echo "			so.addVariable(\"arg".($i+1)."_guid\", \"".$page->guid."\");\n";
				}
			}
			?>
			so.write("headerRightFlash");
		// ]]>
	</script>
    <?php } else { ?>
    <div id="headerRight"><?php
    
		$current = is_front_page() ? "home" : trim( wp_title('',false) );
		
		// print a link for home
		$class = is_front_page() ? "header_link_selected" : "header_link";
		echo "<a href='".implode( explode( '/', $_SERVER['PHP_SELF'], -1 ) , "/" )."' class='$class'>home</a>";
		
		foreach( $pages as $i => $page )
		{
			if( $page->post_status == "publish" )  {
				$class = $page->post_title == $current ? "header_link_selected" : "header_link";
				echo "<a href='".$page->guid."' class='$class'>".strtolower($page->post_title)."</a>";
			}
		}
	
	?></div>
    <?php }
		// where the title swf is
    	$foto_blog_title = implode( "/", explode( "/", $_SERVER['SCRIPT_FILENAME'], -1 ) )."/wp-content/themes/fotoblog/images/FotoBlogTitle.swf";
		//$foto_blog_title = "foo";
		if( file_exists( $foto_blog_title ) ) { ?>
	<div id="headerLeft">&nbsp;</div>
    <script type="text/javascript">
		// <![CDATA[
			var so = new SWFObject("<?php bloginfo('stylesheet_directory'); ?>/images/FotoBlogTitle.swf", "FotoBlogTitle", "375", "80", "9", "#FFFFFF");
			so.addParam("wmode", "transparent");
			so.addVariable("name", "<?php echo get_bloginfo('name'); ?>");
			so.addVariable("description", "<?php echo get_bloginfo('description'); ?>");
			so.addVariable("url", "<?php echo get_bloginfo('home'); ?>");
			so.write("headerLeft");
		// ]]>
	</script>
    <?php } else { ?>
    <div id="headerLeft"><h1><a href="<?php echo get_bloginfo('home'); ?>"><?php echo get_bloginfo('name'); ?></a></h1><h2><?php echo get_bloginfo('description'); ?></h2></div>
    <?php } ?>
</div>
